//
//  JJFriendListSectionHeadView.m
//  List
//
//  Created by itclimb on 2017/8/10.
//  Copyright © 2017年 itclimb.yuancheng.com. All rights reserved.
//

#import "JJFriendListSectionHeadView.h"

@interface JJFriendListSectionHeadView ()

@property(nonatomic, copy) SectionHeadViewBlock block;

@end

@implementation JJFriendListSectionHeadView

- (void)awakeFromNib{
    [super awakeFromNib];
    
    [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapGesture:)]];
    
}

- (void)viewTapGesture:(UITapGestureRecognizer *)recognizer{
    self.group.isSelected = !self.group.isSelected;
    if (self.block) {
        self.block(self.group.isSelected);
    }
}

- (void)setGroup:(JJFriendGroup *)group{
    _group = group;
    self.nameL.text = group.name;
    self.onlineL.text = [NSString stringWithFormat:@"%@/%zd",group.online,group.friends.count];
    if (group.isSelected) {
        self.indicateImageV.transform = CGAffineTransformMakeRotation(M_PI/2);
    }else {
        self.indicateImageV.transform = CGAffineTransformIdentity;
    }
}

/**
 加载xib

 @return xib视图
 */
+ (instancetype)friendListSectionHeadViewFromXib{
    return [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil].lastObject;
}

- (void)setSectionHeadViewBlock:(SectionHeadViewBlock)block{
    _block = block;
}

@end
